﻿/*
Copyright (c) 2010 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using System;
using System.Diagnostics;
using TeachMe.Application.Configuration;
using TeachMe.Application.Properties;

namespace TeachMe.Application.Forms
{
    public partial class NewVersionForm : PseudoModalForm
    {
        private readonly Root _root;

        public NewVersionForm(Root root)
        {
            _root = root;
            _root.MachineSettings.CheckOut();

            InitializeComponent();

            WindowProportions.Lock(this, _root.MachineSettings);
        }

        public void Update(OnlineVersion onlineVersion)
        {
            txSetup.Text = String.Format(Resources.TeachMeInstaller, onlineVersion.Value);
            txPortable.Text = String.Format(Resources.TeachMePortable, onlineVersion.Value);

            hpSetup.Text = onlineVersion.Setup;
            hpPortable.Text = onlineVersion.Portable;
        }

        private void OnFormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
        {
            _root.MachineSettings.CheckIn();
        }

        private void OnSetupLinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(hpSetup.Text);
        }

        private void OnPortableLinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(hpPortable.Text);
        }
    }
}
